package dto

import (
	"github.com/gofrs/uuid"
	"time"
	"vrcm/src/vrcm/app/admin/models/live_schedule"
	"vrcm/src/vrcm/common/dto"
	common "vrcm/src/vrcm/common/models"
)

type ChannelTaskGetPageReq struct {
	dto.Pagination `search:"-"`
	ChannelTaskOrder
}

type ChannelTaskOrder struct {
	Id           string `form:"idOrder"  search:"type:order;column:id;table:channel_task"`
	TenantId     string `form:"tenant_idOrder"  search:"type:order;column:tenant_id;table:channel_task"`
	ChannelId    string `form:"channel_idOrder"  search:"type:order;column:channel_id;table:channel_task"`
	SourceId     string `form:"source_idOrder"  search:"type:order;column:source_id;table:channel_task"`
	TrafficOnId  string `form:"traffic_on_idOrder"  search:"type:order;column:traffic_on_id;table:channel_task"`
	TrafficOffId string `form:"traffic_off_idOrder"  search:"type:order;column:traffic_off_id;table:channel_task"`
	MediaId      string `form:"media_idOrder"  search:"type:order;column:media_id;table:channel_task"`
	TaskState    string `form:"task_stateOrder"  search:"type:order;column:task_state;table:channel_task"`
	TaskId       string `form:"task_idOrder"  search:"type:order;column:task_id;table:channel_task"`
	LiveId       string `form:"live_idOrder"  search:"type:order;column:live_id;table:channel_task"`
	CreateTime   string `form:"create_timeOrder"  search:"type:order;column:create_time;table:channel_task"`
	UpdateTime   string `form:"update_timeOrder"  search:"type:order;column:update_time;table:channel_task"`
	InUdpUrl     string `form:"in_udp_urlOrder"  search:"type:order;column:in_udp_url;table:channel_task"`
	OutUdpUrl    string `form:"out_udp_urlOrder"  search:"type:order;column:out_udp_url;table:channel_task"`
	CreateBy     string `form:"createByOrder"  search:"type:order;column:create_by;table:channel_task"`
	UpdateBy     string `form:"updateByOrder"  search:"type:order;column:update_by;table:channel_task"`
}

func (m *ChannelTaskGetPageReq) GetNeedSearch() interface{} {
	return *m
}

type ChannelTaskInsertReq struct {
	Id           int    `json:"-" comment:""` //
	TenantId     string `json:"tenant_id" comment:"租户"`
	ChannelId    int    `json:"channel_id" comment:"通道id"`
	SourceId     int    `json:"source_id" comment:"信源id"`
	TrafficOnId  int    `json:"traffic_on_id" comment:"上车点id"`
	TrafficOffId int    `json:"traffic_off_id" comment:"下车点id"`
	MediaId      int    `json:"media_id" comment:"媒体处理id"`
	TaskState    int    `json:"task_state" comment:"状态1上线2 下线 3异常"`
	TaskId       string `json:"task_id" comment:"任务id"`
	LiveId       string `json:"live_id" comment:"全球直播任务id"`
	CreateTime   string `json:"create_time" comment:"创建时间"`
	UpdateTime   string `json:"update_time" comment:"更新时间"`
	InUdpUrl     string `json:"in_udp_url" comment:"输入源udp地址"`
	OutUdpUrl    string `json:"out_udp_url" comment:"输出源udp地址"`
	common.ControlBy
}

func (s *ChannelTaskInsertReq) Generate(model *live_schedule.ChannelTask) {
	if s.Id == 0 {
		model.Model = common.Model{Id: s.Id}
	}
	now := time.Now().Unix()
	model.TenantId = s.TenantId
	model.ChannelId = s.ChannelId
	model.SourceId = s.SourceId
	model.TrafficOnId = s.TrafficOnId
	model.TrafficOffId = s.TrafficOffId
	model.MediaId = s.MediaId
	model.TaskState = s.TaskState
	model.TaskId = s.TaskId
	model.LiveId = s.LiveId
	model.CreateTime = now
	model.UpdateTime = now
	model.InUrl = s.InUdpUrl
	model.OutUrl = s.OutUdpUrl
	model.CreateBy = s.CreateBy // 添加这而，需要记录是被谁创建的
}

func (s *ChannelTaskInsertReq) GetId() interface{} {
	return s.Id
}

type ChannelTaskUpdateReq struct {
	Id           int    `uri:"id" comment:""` //
	TenantId     string `json:"tenant_id" comment:"租户"`
	ChannelId    int    `json:"channel_id" comment:"通道id"`
	SourceId     int    `json:"source_id" comment:"信源id"`
	TrafficOnId  int    `json:"traffic_on_id" comment:"上车点id"`
	TrafficOffId int    `json:"traffic_off_id" comment:"下车点id"`
	MediaId      int    `json:"media_id" comment:"媒体处理id"`
	TaskState    int    `json:"task_state" comment:"状态1上线2 下线 3异常"`
	TaskId       string `json:"task_id" comment:"任务id"`
	LiveId       string `json:"live_id" comment:"全球直播任务id"`
	CreateTime   string `json:"create_time" comment:"创建时间"`
	UpdateTime   string `json:"update_time" comment:"更新时间"`
	InUrl        string `json:"in_url" comment:"输入源udp地址"`
	OutUrl       string `json:"out_url" comment:"输出源udp地址"`
	common.ControlBy
}

func (s *ChannelTaskUpdateReq) Generate(model *live_schedule.ChannelTask) {
	if s.Id == 0 {
		model.Model = common.Model{Id: s.Id}
	}
	now := time.Now().Unix()
	model.TenantId = s.TenantId
	model.ChannelId = s.ChannelId
	model.SourceId = s.SourceId
	model.TrafficOnId = s.TrafficOnId
	model.TrafficOffId = s.TrafficOffId
	model.MediaId = s.MediaId
	model.TaskState = s.TaskState
	model.TaskId = s.TaskId
	model.LiveId = s.LiveId
	model.UpdateTime = now
	model.InUrl = s.InUrl
	model.OutUrl = s.OutUrl
	model.UpdateBy = s.UpdateBy // 添加这而，需要记录是被谁更新的
}

func (s *ChannelTaskUpdateReq) GetId() interface{} {
	return s.Id
}

// ChannelTaskGetReq 功能获取请求参数
type ChannelTaskGetReq struct {
	Id      int `uri:"id"`
	IsGroup int `json:"is_group" comment:"是否为组"`
}

func (s *ChannelTaskGetReq) GetId() interface{} {
	return s.Id
}

// ChannelTaskDeleteReq 功能删除请求参数
type ChannelTaskDeleteReq struct {
	Ids []int `json:"ids"`
}

func (s *ChannelTaskDeleteReq) GetId() interface{} {
	return s.Ids
}

type TrafficOnSaveReq struct {
	Id            int    `json:"id" comment:""` //
	TenantId      string `json:"tenant_id" comment:"租户"`
	ChannelId     int    `json:"channel_id" comment:"通道id"`
	SourceId      int    `json:"source_id" comment:"信源或信源组id"`
	TrafficOnName string `json:"traffic_on_name" comment:"上车点名称"`
	TrafficOnType int    `json:"traffic_on_type" comment:"1信源池 2信源组 3 rtmp 4 hls 5https  6srt 7udp 8sdi"`
	IsGroup       int    `json:"is_group" comment:"是否是组 1是 2否"`
	StreamType    int    `json:"stream_type" comment:"流类型 1原始流 2转码流"`
	NodeId        string `json:"node_id" comment:"node_id"`
	TransUdpUrl   string `json:"trans_udp_url" comment:"转码后的udp地址"`
	TransTaskId   string `json:"trans_task_id" comment:"转码任务id"`
	TransRecordId int    `json:"trans_record_id" comment:"转码任务记录id"`
	TemplateId    string `json:"template_id" comment:"转码模版ID"`
	Kind          int    `json:"kind" comment:"1原始信源 2自定义信源 3设备"`
	EqUrl         string `json:"eq_url" comment:"设备地址"`
	common.ControlBy
}

type TrafficOnsSaveReq struct {
	Id                int                 `json:"id" comment:""` //
	GroupName         string              `json:"group_name" comment:"组名称"`
	TrafficOnName     string              `json:"traffic_on_name" comment:"上车点名称"`
	TenantId          string              `json:"tenant_id" comment:"租户"`
	ChannelId         int                 `json:"channel_id" comment:"通道id"`
	SourceId          int                 `json:"source_id" comment:"组id"`
	TrafficOnSaveReqs *[]TrafficOnSaveReq `json:"traffic_on_save_reqs" comment:"请求参数"`
}

type TrafficOnsSaveRes struct {
	Id                int                `json:"id" comment:""` //
	NodeId            string             `json:"node_id" comment:"节点id"`
	TrafficOnSaveReqs []TrafficOnSaveReq `json:"traffic_on_save_reqs" comment:"返回参数"`
}

func (s *TrafficOnSaveReq) Generate(model *live_schedule.TrafficOn) {
	now := time.Now().Unix()
	model.Id = s.Id
	model.TenantId = s.TenantId
	model.ChannelId = s.ChannelId
	model.SourceId = s.SourceId
	model.TrafficOnName = s.TrafficOnName
	model.TrafficOnType = s.TrafficOnType
	model.IsGroup = s.IsGroup
	model.StreamType = s.StreamType
	model.TemplateId = s.TemplateId
	model.TransRecordId = s.TransRecordId
	if model.Id > 0 {
		model.CreateTime = now
		model.UpdateTime = now
		model.CreateBy = s.CreateBy
	} else {
		u, _ := uuid.NewV4()
		model.NodeId = u.String()
		model.CreateTime = now
		model.UpdateTime = now
		model.UpdateBy = s.UpdateBy
		model.TrafficOnState = 2
	}
	model.TransTaskId = s.TransTaskId
	model.TransUdpUrl = s.TransUdpUrl
	model.Kind = s.Kind
	model.EqUrl = s.EqUrl
	model.IsDelete = 2
}

type TrafficOnGetReq struct {
	dto.Pagination `search:"-"`
	Id             int   `json:"id" comment:"上车点id"`
	IsGroup        int64 `json:"is_group" comment:"是否是组 1是 2否"`
	StreamType     int   `json:"stream_type" gorm:"type:tinyint;comment:流类型 1原始流 2转码流"`
}

type TrafficOnGetRes struct {
	TrafficOn            *live_schedule.TrafficOn             `json:"traffic_on"`
	TrafficOns           *[]live_schedule.TrafficOn           `json:"traffic_ons"`
	SourceModelRes       *[]SourceModelRes                    `json:"source_model_res"`
	SourceTemplateModels *[]live_schedule.SourceTemplateModel `json:"source_template_models"`
}

type TrafficOnDeleteReq struct {
	Id int `uri:"id"`
}

type MediaProcessSaveReq struct {
	Id           int    `json:"id" comment:""` //
	TenantId     string `json:"tenant_id" comment:"租户"`
	ChannelId    int    `json:"channel_id" comment:"通道id"`
	MediaName    string `json:"media_name" comment:"媒体处理名称"`
	MediaType    int    `json:"media_type" comment:"媒体处理类型 1汇聚协转 2软矩阵 3审核 4转码 5录制"`
	PlayType     int    `json:"play_type" comment:"播放模式 1正常 2延迟"`
	Delay        int    `json:"delay" comment:"延迟秒数"`
	NodeId       string `json:"node_id" comment:"节点唯一id"`
	EnableAi     int    `json:"enable_ai" comment:"是否启用 1是 2否"`
	Frequency    int    `json:"frequency" comment:"频率 5s抽一帧"`
	TemplateId   string `json:"template_id" comment:"模版ID"`
	ExtraInfo    string `json:"extra_info" comment:"额外信息"`
	EnableSwitch int    `json:"enable_switch" comment:"是否启用 1是 2否"`
	common.ControlBy
}

func (s *MediaProcessSaveReq) Generate(model *live_schedule.MediaProcess) {
	now := time.Now().Unix()
	model.Id = s.Id
	model.TenantId = s.TenantId
	model.ChannelId = s.ChannelId
	model.MediaName = s.MediaName
	model.MediaType = s.MediaType
	model.PlayType = s.PlayType
	model.Delay = s.Delay
	model.EnableAi = s.EnableAi
	model.Frequency = s.Frequency
	if model.Id > 0 {
		model.CreateTime = now
		model.UpdateTime = now
		model.CreateBy = s.CreateBy
	} else {
		u, _ := uuid.NewV4()
		model.NodeId = u.String()
		model.CreateTime = now
		model.UpdateTime = now
		model.UpdateBy = s.UpdateBy
		model.MediaState = 3
	}
	model.TemplateId = s.TemplateId
	model.ExtraInfo = s.ExtraInfo
	model.EnableSwitch = s.EnableSwitch
}

type MediaProcessGetReq struct {
	Id int `uri:"id"`
}

type MediaProcessDeleteReq struct {
	Id int `uri:"id"`
}

type TrafficOffSaveReq struct {
	Id               int                     `json:"id" comment:""` //
	TenantId         string                  `json:"tenant_id" comment:"租户"`
	ChannelId        int                     `json:"channel_id" comment:"通道id"`
	TrafficOffName   string                  `json:"traffic_off_name" comment:"下车点名称"`
	TrafficOffType   int                     `json:"traffic_off_type" comment:"1rtmp 2flv 3hls 4https 5 srt 6udp 7flv 8sdi 9外场设备"`
	Area             int                     `json:"area" comment:"区域1.国内互联网 2国际互联网 3.台内内网"`
	StreamType       int                     `json:"stream_type" comment:"流类型 1推流至第三方 2第三方拉流"`
	PushUrl          string                  `json:"push_url" comment:"推流地址"`
	NodeId           string                  `json:"node_id" comment:"节点唯一id"`
	IsCustom         int                     `json:"is_custom" comment:"是否自定义 1是 2否"`
	AreaType         string                  `json:"area_type" comment:"区域"`
	PushInfos        []PushInfo              `json:"push_infos"`
	PullInfos        []PullInfo              `json:"pull_infos"`
	EnableBlackWhite int                     `json:"enable_black_white" comment:"1启用 2不启用"`
	ListType         int                     `json:"list_type" comment:"1黑名单 2白名单"`
	IPAddresses      []string                `json:"ip_addresses" comment:"ip地址"`
	EquipCode        string                  `json:"equip_no" comment:"设备编号"`
	ChartData        live_schedule.ChartData `json:"chart_data" comment:""`
	common.ControlBy
}

func (s *TrafficOffSaveReq) Generate(model *live_schedule.TrafficOff) {
	now := time.Now().Unix()
	model.TenantId = s.TenantId
	model.ChannelId = s.ChannelId
	model.TrafficOffName = s.TrafficOffName
	model.TrafficOffType = s.TrafficOffType
	model.Area = s.Area
	model.StreamType = s.StreamType
	model.PushUrl = s.PushUrl
	model.IsCustom = s.IsCustom
	model.AreaType = s.AreaType
	model.EnableBlackWhite = s.EnableBlackWhite
	model.ListType = s.ListType
	if model.Id > 0 {
		model.CreateTime = now
		model.UpdateTime = now
		model.CreateBy = s.CreateBy
	} else {
		u, _ := uuid.NewV4()
		model.NodeId = u.String()
		model.CreateTime = now
		model.UpdateTime = now
		model.UpdateBy = s.UpdateBy
		model.TrafficOffState = 2
	}
	model.EquipCode = s.EquipCode
}

type TrafficOffGetReq struct {
	Id int `json:"id"`
	//UpIds   []int `json:"up_ids"`
	//MediaId int   `json:"media_id"`
}

type TrafficOffDeleteReq struct {
	Id int `uri:"id"`
}

type GetWorkflowReq struct {
	TenantId  string `json:"tenant_id" comment:"租户"`
	ChannelId int    `json:"channel_id" comment:"通道id"`
}

type GetWorkflowRes struct {
	WorkflowUp    *[]WorkflowUp    `json:"workflow_up"`
	WorkflowMedia *[]WorkflowMedia `json:"workflow_media"`
	WorkflowDown  *[]WorkflowDown  `json:"workflow_down"`
	PushInfos     *[]PushInfo      `json:"push_infos"`
}

type SaveWorkflowReq struct {
	TenantId      string          `json:"tenant_id" comment:"租户"`
	ChannelId     int             `json:"channel_id" comment:"通道id"`
	WorkflowMedia []WorkflowMedia `json:"workflow_media"`
	PushInfos     []PushInfo      `json:"push_infos"`
	PullInfos     []PullInfo      `json:"pull_infos"`
	//UpAudits      []int           `json:"up_audits"`
	//AuditMedia    int             `json:"audit_media"`
	//OutputNames   []string        `json:"output_names" comment:"输出名称" validate:"required"`
	ChartData    live_schedule.ChartData `json:"chart_data"`
	NewChartData string                  `json:"new_chart_data"`
}

type ChangeNodeInfo struct {
	NodeId       string `json:"node_id"`
	OperatorType string `json:"operator_type"`
}

type AuditMedia struct {
	UpId    int    `json:"up_id"`
	AuditId string `json:"audit_id"`
}

type PullInfo struct {
	SourceId      int    `json:"source_id" comment:"信源id"`
	UpId          int    `json:"up_id" comment:"上车id"`
	MediaId       int    `json:"media_id" comment:"媒体处理id"`
	OffId         int    `json:"off_id" comment:"上车id"`
	PullUrl       string `json:"pull_url" comment:"拉流地址"`
	CortexOutId   int    `json:"cortex_out_id" comment:"上车id"`
	OriginPullUrl string `json:"origin_pull_url" comment:"原始拉流地址"`
	CortexOutName string `json:"cortex_out_name" comment:"输出名"`
}

type PushInfo struct {
	SourceId      int    `json:"source_id" comment:"信源id"`
	UpId          int    `json:"up_id" comment:"上车id"`
	MediaId       int    `json:"media_id" comment:"媒体处理id"`
	OffId         int    `json:"off_id" comment:"下车id"`
	CortexOutId   int    `json:"cortex_out_id" comment:"输出id"`
	CortexOutName string `json:"cortex_out_name" comment:"输出名"`
	PushUrl       string `json:"push_url" comment:"第三方推流地址"`
}

type ProcessWorkflowReq struct {
	TenantId   string `json:"tenant_id" comment:"租户"`
	ChannelId  int    `json:"channel_id" comment:"通道id"`
	TimeTaskId int    `json:"time_task_id" comment:"定时任务id"`
	StartType  int    `json:"start_type" comment:"1立即开始"`
	//EndTime      int64  `json:"end_time" comment:"结束时间"`
}

type WorkflowUp struct {
	Id                      string                        `json:"id"`
	TransferContentId       string                        `json:"transfer_content_id"`
	TransferMediaId         interface{}                   `json:"transfer_media_id"`
	CreateTime              string                        `json:"create_time"`
	Status                  string                        `json:"status"`
	TrafficOn               *live_schedule.TrafficOnModel `json:"configuration"`
	GroupTrafficOn          *live_schedule.TrafficOnModel `json:"group_traffic_on"`
	Num                     int                           `json:"num"`
	LiveId                  interface{}                   `json:"live_id"`
	AccelerateDomain        interface{}                   `json:"accelerate_domain"`
	AcceleratePort          interface{}                   `json:"accelerate_port"`
	AccelerateId            interface{}                   `json:"accelerate_id"`
	PullLiveId              interface{}                   `json:"pull_live_id"`
	GroupId                 interface{}                   `json:"groupId"`
	Virtual                 interface{}                   `json:"virtual"`
	VirtualRefId            interface{}                   `json:"virtualRefId"`
	StreamId                string                        `json:"streamId"`
	TransferState           interface{}                   `json:"transferState"`
	TransferStateUpdatetime interface{}                   `json:"transferState_updatetime"`
	GroupFlag               string                        `json:"groupFlag"`
	GroupKey                interface{}                   `json:"groupKey"`
	DelayStreamId           interface{}                   `json:"delayStreamId"`
	X                       int                           `json:"x"`
	Y                       int                           `json:"y"`
	SourceModelRes          *SourceModelRes               `json:"source_model_res"`
}

type WorkflowMedia struct {
	Id                      string                     `json:"id"`
	TransferContentId       int                        `json:"transfer_content_id"`
	TransferUpPointId       []int                      `json:"transfer_up_point_id"`
	TransferDownPointId     []int                      `json:"transfer_down_point_id"`
	TransferMediaPointId    int                        `json:"transfer_media_point_id"`
	TransferAuditPointId    []int                      `json:"transfer_audit_point_id"`
	CreateTime              string                     `json:"create_time"`
	Status                  interface{}                `json:"status"`
	MediaProcess            live_schedule.MediaProcess `json:"configuration"`
	Num                     int                        `json:"num"`
	TaskId                  interface{}                `json:"task_id"`
	GroupId                 interface{}                `json:"groupId"`
	Virtual                 interface{}                `json:"virtual"`
	WorkProcess             interface{}                `json:"workProcess"`
	ProcessMessage          interface{}                `json:"processMessage"`
	VirtualRefId            interface{}                `json:"virtualRefId"`
	TransferState           string                     `json:"transferState"`
	TransferStateUpdatetime interface{}                `json:"transferState_updatetime"`
	GroupFlag               string                     `json:"groupFlag"`
	GroupKey                interface{}                `json:"groupKey"`
	X                       float64                    `json:"x"`
	Y                       int                        `json:"y"`
	AuditStatisticRes       AuditStatisticRes          `json:"audit_statistic_res"`
}

type WorkflowDown struct {
	Id                string                   `json:"id"`
	TransferContentId string                   `json:"transfer_content_id"`
	TransferMediaId   interface{}              `json:"transfer_media_id"`
	CreateTime        int64                    `json:"create_time"`
	Status            string                   `json:"status" comment:"1正常 2异常 3审核不通过"`
	TrafficOff        live_schedule.TrafficOff `json:"configuration"`
	Num               int                      `json:"num"`
	LiveId            interface{}              `json:"live_id"`
	AccelerateDomain  interface{}              `json:"accelerate_domain"`
	AcceleratePort    interface{}              `json:"accelerate_port"`
	AccelerateId      interface{}              `json:"accelerate_id"`
	PlayUrl           interface{}              `json:"playUrl"`
	StreamName        interface{}              `json:"streamName"`
	RtmpPushUrl       interface{}              `json:"rtmpPushUrl"`
	//VsPackageTaskID         interface{}              `json:"vs_packageTaskID"`
	VsPlayUrl               interface{} `json:"vs_playUrl"`
	VsStreamName            interface{} `json:"vs_streamName"`
	VsRtmpPushUrl           interface{} `json:"vs_rtmpPushUrl"`
	PullUrls                string      `json:"pullUrls"`
	Protocol                interface{} `json:"protocol"`
	Url                     interface{} `json:"url"`
	GroupId                 interface{} `json:"groupId"`
	Virtual                 interface{} `json:"virtual"`
	VirtualRefId            interface{} `json:"virtualRefId"`
	TransferState           string      `json:"transferState"`
	TransferStateUpdatetime interface{} `json:"transferState_updatetime"`
	GroupFlag               string      `json:"groupFlag"`
	GroupKey                interface{} `json:"groupKey"`
	X                       float64     `json:"x"`
	Y                       int         `json:"y"`
	PushInfos               []PushInfo  `json:"push_infos"`
	PullInfos               []PullInfo  `json:"pull_infos"`
}

type TargetCallBackReq struct {
	Id                          string  `json:"id" comment:"任务主id"`
	TaskId                      string  `json:"taskId" comment:"任务子id"`
	TransferState               string  `json:"transferState" comment:"状态"`
	TransferStateLastUpdateTime float64 `json:"transferStateLastUpdateTime" comment:"任务更新时间"`
}

type NodeInfo struct {
	Id     int    `json:"id" comment:"id"`
	NodeId string `json:"node_id" comment:"node_id"`
}

type GetChannelTaskStatisticsReq struct {
	TenantId string `json:"tenant_id" comment:"租户"`
}

type ChannelTaskStatistics struct {
	TotalCount  int `json:"total_count" comment:"总数"`
	NormalCount int `json:"normal_count" comment:"正常数"`
	FailCount   int `json:"fail_count" comment:"异常数"`
	OffCount    int `json:"off_count" comment:"下线数"`
}

type GetScheduleStatisticsReq struct {
	TenantId  string `json:"tenant_id" comment:"租户"`
	StartTime int    `json:"start_time" comment:"开始时间"`
	EndTime   int    `json:"end_time" comment:"结束时间"`
	ChannelId int    `json:"channel_id" comment:"通道id"`
	Type      int    `json:"type" comment:"1 通道时长 2 转码时长 3录制时长 4审核时常"`
}

type UpdateCortexOutput struct {
	Id          int          `json:"id" comment:"输出名称id" validate:"required"`
	OutputName  string       `json:"output_name" comment:"输出名" validate:"required"`
	CortexInfos []CortexInfo `json:"cortex_infos" comment:"输出名称"`
}

type SaveCortexReq struct {
	TenantId    string       `json:"tenant_id" comment:"租户" validate:"required"`
	CortexInfos []CortexInfo `json:"cortex_infos" comment:"输出名称"`
	ChannelId   int          `json:"channel_id" comment:"频道id" validate:"gt=0"`
	PushInfos   []PushInfo   `json:"push_infos" comment:"推流地址"`
	PullInfos   []PullInfo   `json:"pull_infos" comment:"拉流地址"`
}

type CortexInfo struct {
	OutputName string `json:"output_name" comment:"输出名称"`
	//UpId       int    `json:"up_id" comment:"上车点id" validate:"gt=0"`
	OffId   int    `json:"off_id" comment:"上车id"`
	PushUrl string `json:"push_url" comment:"推流地址"`
	PullUrl string `json:"pull_url" comment:"拉流地址"`
}

type CreateCortexTaskReq struct {
	TenantId       string `json:"tenant_id" comment:"租户" validate:"required"`
	ChannelId      int    `json:"channel_id" comment:"频道id" validate:"gt=0"`
	UpId           int    `json:"up_id" comment:"上车点id" validate:"gt=0"`
	CortexOutputId int    `json:"cortex_output_id" comment:"矩阵输出id" validate:"gt=0"`
	//OffIds         []int  `json:"off_ids" comment:"下车点id"`
}

type StopCortexTaskReq struct {
	TenantId       string `json:"tenant_id" comment:"租户" validate:"required"`
	ChannelId      int    `json:"channel_id" comment:"频道id" validate:"gt=0"`
	UpId           int    `json:"up_id" comment:"上车点id" validate:"gt=0"`
	CortexOutputId int    `json:"cortex_output_id" comment:"矩阵输出id" validate:"gt=0"`
}

type StartCortexTaskReq struct {
	TenantId       string `json:"tenant_id" comment:"租户" validate:"required"`
	ChannelId      int    `json:"channel_id" comment:"频道id" validate:"gt=0"`
	UpId           int    `json:"up_id" comment:"上车点id" validate:"gt=0"`
	CortexOutputId int    `json:"cortex_output_id" comment:"矩阵输出id" validate:"gt=0"`
}

type DeleteCortexTaskReq struct {
	TenantId  string `json:"tenant_id" comment:"租户" validate:"required"`
	ChannelId int    `json:"channel_id" comment:"频道id" validate:"gt=0"`
	//MediaId        int    `json:"media_id" comment:"媒体处理id" validate:"gt=0"`
	CortexOutputId int `json:"cortex_output_id" comment:"矩阵输出id"`
	//UpId           int `json:"up_id" comment:"上车点id"`
	//SourceId       int `json:"source_id" comment:"信源id"`
}

type SwitchCortexSourceReq struct {
	TenantId  string `json:"tenant_id" comment:"租户" validate:"required"`
	ChannelId int    `json:"channel_id" comment:"频道id" validate:"gt=0"`
	//MediaId    int    `json:"media_id" comment:"媒体处理id" validate:"gt=0"`
	OriginUpId     int `json:"origin_up_id" comment:"上车点id" validate:"gt=0"`
	TargetUpId     int `json:"target_up_id" comment:"目标信源id"`
	CortexOutputId int `json:"cortex_output_id" comment:"矩阵输出id"`
	ActiveItem     int `json:"active_item" comment:"切换目标"`
}

type GetCortexTaskListReq struct {
	TenantId  string `json:"tenant_id" comment:"租户"`
	ChannelId int    `json:"channel_id" comment:"频道id"`
	//MediaId   int    `json:"media_id" comment:"媒体处理id" validate:"gt=0"`
	CortexOutputIds []int  `json:"cortex_output_ids" comment:"矩阵输出id"`
	SourceIds       []int  `json:"source_ids" comment:"信源id"`
	InputName       string `json:"input_name" comment:"输入名称"`
	OutPutName      string `json:"output_name" comment:"矩阵输出id"`
}

type GetCortexOutInfo struct {
	TenantId       string `json:"tenant_id" comment:"租户" validate:"required"`
	ChannelId      int    `json:"channel_id" comment:"频道id" validate:"gt=0"`
	CortexOutputId int    `json:"cortex_output_id" comment:"矩阵输出id"`
	UpId           int    `json:"up_id" comment:"目标信源id"`
}

type CortexTaskRes struct {
	CortexTaskModels *[]live_schedule.CortexTaskModel `json:"cortex_task_models" comment:"矩阵详情"`
	CortexOutputs    *[]live_schedule.CortexOutput    `json:"cortex_outputs" comment:"矩阵输出名"`
	TrafficOns       *[]TrafficOnRes                  `json:"trafficOns" comment:"上车点"`
	TrafficOffs      *[]live_schedule.TrafficOff      `json:"traffic_offs" comment:"下车点"`
}

type TrafficOnRes struct {
	TrafficOn            *live_schedule.TrafficOnModel        `json:"traffic_on" comment:"上车点"`
	SourceModelRes       *SourceModelRes                      `json:"source_model_res"`
	SourceTemplateModels *[]live_schedule.SourceTemplateModel `json:"source_template_models"`
	SourceState          int                                  `json:"source_state" comment:"信源状态 1启用 2停用3 异常"`
}

type EnableOrCancelTimeTaskReq struct {
	TenantId     string `json:"tenant_id" comment:"租户"`
	ChannelId    int    `json:"channel_id" comment:"频道id" validate:"gt=0"`
	StartTime    int    `json:"start_time" comment:"开始时间"`
	EndTime      int    `json:"end_time" comment:"结束时间"`
	TimeType     int    `json:"time_type" comment:"启停类型1不重复 2每天 3 每周"`
	CycleEndTime int    `json:"cycle_end_time" comment:"周期行结束时间"`
	Weekly       string `json:"weekly" comment:"每周执行日期 0 星期天 1星期一 2星期二 。。。。。" `
}

type StartOrStopTimeTaskReq struct {
	ChannelId int `json:"channel_id" comment:"频道id" validate:"gt=0"`
	IsTime    int `json:"is_time" comment:"是否定时"`
}

type GetCortexReq struct {
	TenantId   string `json:"tenant_id" comment:"租户" `
	ChannelId  int    `json:"channel_id" comment:"频道id""`
	InputName  string `json:"input_name" comment:"输入名称"`
	OutPutName string `json:"output_name" comment:"矩阵输出id"`
}

type AuditResult struct {
	ErrorCode         int          `json:"errorCode"`
	ErrorMsg          string       `json:"errorMsg"`
	TaskId            string       `json:"taskId"`
	VideoTaskDuration int64        `json:"videoTaskDuration"`
	AudioTaskDuration int64        `json:"audioTaskDuration"`
	VideoFrameList    []VideoFrame `json:"videoFrameList"`
	AudioFrameList    []AudioFrame `json:"audioFrameList"`
}

type VideoFrame struct {
	FrameAuditResult FrameAuditResult `json:"frameAuditResult"`
	FrameTimestamp   int              `json:"frameTimestamp"`
	FrameUrl         string           `json:"frameUrl"`
}

type FrameAuditResult struct {
	Conclusion     string      `json:"conclusion"`
	LogId          string      `json:"logId"`
	Data           []VideoData `json:"data"`
	IsHitMd5       bool        `json:"isHitMd5"`
	ConclusionType int         `json:"conclusionType"`
}

type VideoData struct {
	Msg            string  `json:"msg"`
	Conclusion     string  `json:"conclusion" comment:"1：合规，2：不合规，3：疑似，4：审核失败"`
	Probability    float64 `json:"probability"`
	SubType        int     `json:"subType"`
	ConclusionType int     `json:"conclusionType"`
	Type           int     `json:"type"`
}

type AudioFrame struct {
	AudioAuditResult AudioAuditResult `json:"audioAuditResult"`
	AudioUrl         string           `json:"audioUrl"`
	EndTime          int              `json:"endTime"`
	StartTime        int              `json:"startTime"`
}

type AudioAuditResult struct {
	Conclusion     string      `json:"conclusion"`
	LogId          string      `json:"logId"`
	Data           []AuditData `json:"data"`
	RawText        []string    `json:"rawText"`
	ConclusionType int         `json:"conclusionType"`
	Sn             string      `json:"sn"`
}

type AudioData struct {
	Conclusion     string      `json:"conclusion"`
	AuditData      []AuditData `json:"auditData"`
	StartTime      int         `json:"startTime"`
	ConclusionType int         `json:"conclusionType"`
	EndTime        int         `json:"endTime"`
	Text           string      `json:"text"`
}

type AuditData struct {
	Hits    []Hits `json:"hits"`
	Msg     string `json:"msg"`
	SubType int    `json:"subType"`
	Type    int    `json:"type"`
}

type Hits struct {
	Probability float64       `json:"probability"`
	DatasetName string        `json:"datasetName"`
	Words       []interface{} `json:"words"`
}

type SaveAuditTask struct {
	TenantId  string `json:"tenant_id" comment:"租户"`
	ChannelId int    `json:"channel_id" comment:"频道id"`
	MediaId   int    `json:"media_id" comment:"媒体id"`
}

type AuditStatisticReq struct {
	TenantId  string `json:"tenant_id" comment:"租户" `
	ChannelId int    `json:"channel_id" comment:"频道id""`
	Type      int    `json:"type" comment:"1色情识别、2暴力、3恶心、4广告、5政治敏感 6其他"`
}

type AuditStatisticRes struct {
	Task     string `json:"task" comment:"审核任务"`
	SourceId int    `json:"source_id" comment:"信源"`
	Type1Num int    `json:"type1_num" comment:"色情" `
	Type2Num int    `json:"type2_num" comment:"暴力"`
	Type3Num int    `json:"type3_num" comment:"恶心"`
	Type4Num int    `json:"type4_num" comment:"广告"`
	Type5Num int    `json:"type5_num" comment:"政治"`
	Type6Num int    `json:"type6_num" comment:"其他"`
}

type AuditStatisticDetailRes struct {
	SourceId      int `json:"source_id" comment:"信源"`
	ChannelId     int `json:"channel_id" comment:"频道id"`
	ViolationType int `json:"violation_type" comment:"违规类型 1色情识别、2暴力、3恶心、4广告、5政治敏感 6其他"`
	TypeNum       int `json:"type_num" comment:"数量"`
}

type MediaProcessModel struct {
	MediaProcess      live_schedule.MediaProcess `json:"mediaProcess"`
	AuditStatisticRes []AuditStatisticRes        `json:"audit_statistic_res"`
}

type CheckUpUsedReq struct {
	UpId int `json:"up_id" comment:"上车点" `
}

type AuditResult1 struct {
	MessageId   string      `json:"messageId"`
	MessageBody MessageBody `json:"messageBody"`
}

type MessageBody struct {
	EvidenceTime string   `json:"evidenceTime"`
	AudioUrl     string   `json:"audioUrl"`
	ThumbnailUrl string   `json:"thumbnailUrl"`
	Results      []Result `json:"results"`
	Source       string   `json:"source"`
	Preset       string   `json:"preset"`
	Description  string   `json:"description"`
	Notification string   `json:"notification"`
	MediaId      string   `json:"mediaId"`
	Label        string   `json:"label"`
}

type Result struct {
	Type  string `json:"type"`
	Items []Item `json:"items"`
}

type Item struct {
	SubType            string   `json:"subType"`
	Target             string   `json:"target"`
	TimeInSeconds      int      `json:"target"`
	StartTimeInSeconds int      `json:"startTimeInSeconds"`
	EndTimeInSeconds   int      `json:"endTimeInSeconds"`
	Confidence         float64  `json:"confidence"`
	Label              string   `json:"label"`
	Extra              string   `json:"extra"`
	Evidence           Evidence `json:"evidence"`
}

type Evidence struct {
	Thumbnail string   `json:"thumbnail"`
	Location  Location `json:"location"`
	Text      string   `json:"text"`
}

type Location struct {
	LeftOffsetInPixel int `json:"leftOffsetInPixel"`
	TopOffsetInPixel  int `json:"topOffsetInPixel"`
	WidthInPixel      int `json:"widthInPixel"`
	HeightInPixel     int `json:"heightInPixel"`
}

type StopOrStopTaskByTrafficOnReq struct {
	UpId int `json:"up_id" comment:"上车点" validate:"gt=0"`
	Type int `json:"type" comment:"1 开启 2停止" validate:"gt=0"`
}

type StopOrStopTaskByTrafficOffReq struct {
	OffId int `json:"off_id" comment:"下车点" validate:"gt=0"`
	Type  int `json:"type" comment:"1 开启 2停止" validate:"gt=0"`
}

type StopOrStopTaskByMediaProcessReq struct {
	MediaProcessId int `json:"media_process_id" comment:"中间节点" validate:"gt=0"`
	TrafficOnId    int `json:"traffic_on_id" comment:"中间节点"`
	Type           int `json:"type" comment:"1 开启 2停止" validate:"gt=0"`
}

type SaveCycleTimeReq struct {
	ChannelId  int                       `json:"channel_id" comment:"频道"`
	CycleTimes []live_schedule.CycleTime `json:"cycle_times" comment:""`
}

type GetCycleTimeReq struct {
	dto.Pagination `search:"-"`
	ChannelId      int   `json:"channel_id" comment:"频道" search:"-"`
	StartTime      int64 `json:"start_time" comment:"开始时间" search:"-"`
}

type DeleteCycleTimeReq struct {
	ChannelId int `json:"channel_id" comment:"频道""`
}

type GenerateCycleTimeReq struct {
	ChannelId int `json:"channel_id" comment:"频道""`
}

type CancelCycleTimeReq struct {
	Id int `json:"id" comment:"id"`
}

func (m *GetCycleTimeReq) GetNeedSearch() interface{} {
	return *m
}

type GetUpMediaReq struct {
	MediaProcessId int `json:"media_process_id" comment:"中间节点"`
}

type CallBackData struct {
	TaskId            string  `json:"task_id" comment:"任务id"`
	State             int     `json:"state" comment:"任务状态"`
	TotalNum          int     `json:"total_num" comment:"总任务数"`
	ProcessedNum      int     `json:"processed_num" comment:"已完成任务数"`
	InputVideoInfo    string  `json:"input_video_info" comment:"输入流的状态"`
	OutputVideoInfo   string  `json:"output_video_info" comment:"输出流的状态"`
	RealTimeVideoInfo string  `json:"real_time_video_info" comment:"实时状态"`
	FilePath          string  `json:"file_path" comment:"文件路径"`
	ErrMsg            string  `json:"error_msg" comment:"文件错误"`
	StartTime         int     `json:"start_time" comment:"开始时间"`
	EndTime           int     `json:"end_time" comment:"结束时间"`
	ProcessTime       float64 `json:"process_time" comment:"已完成时间"`
}

type StartOrStopNodeReq struct {
	NodeId    string `json:"node_id" comment:"node_id"`
	ChannelId int    `json:"channel_id" comment:""`
	Type      int    `json:"type" comment:"1 启用 2停用"`
}

type SwitchSourceReq struct {
	NodeId    string `json:"node_id" comment:"node_id"`
	ChannelId int    `json:"channel_id" comment:""`
	Active    int    `json:"active" comment:"1 启用 2停用"`
}

type MediaProcessSaveReq1 struct {
	Id        int                    `json:"id" comment:""` //
	TenantId  string                 `json:"tenant_id" comment:"租户"`
	ChannelId int                    `json:"channel_id" comment:"通道id"`
	NodeData  live_schedule.NodeData `json:"node_data" comment:"通道id"`
	common.ControlBy
}
